using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Ordinaire;
using Ordinaire.Database;

namespace Example
{
	public partial class _Default : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			IDatabase database = DatabaseFactory.CreateInstances("ouija", true);
			ORMapper.Instance.LoadAll(Server.MapPath("~/App_Data/"));

			OuijaUser user = new OuijaUser();
			user.User_Name = "ouija_admin";
			user.User_Pwd = "ouija_spirit2";
			user.Update();

			user.text = "apa";
			user.Update();

			List<User> users = ORMapper.Instance.ExecuteQuery("getAllUsers").ConvertAll<User>(new Converter<object,User>(ObjectToUser));
			if (users != null)
			{
				rptUser.DataSource = users;
				rptUser.DataBind();
			}
		}

		private User ObjectToUser(object value)
		{
			return (User)value;
		}
	}
}
